
const Model =require('../index')

module.exports=class News extends Model{
    static getNewsType(){
        return new Promise((resolve,reject)=>{
            const sql='select * from news_type where state=1'
            this.query(sql).then(result=>{
                resolve(result)
            }).catch(err=>{
                reject(err)
            })
        })
    }
    static getNews(type_id){
        return new Promise((resolve,reject)=>{
            const sql='select * from news where type_id=?'
            this.query(sql,[type_id]).then(result=>{
                resolve(result)
            }).catch(err=>{
                reject(err)
            })
        })
    }
    static getNewsDetail(id){
        return new Promise((resolve,reject)=>{
            const sql='select * from news where id=?'
            this.query(sql,[id]).then(result=>{
                resolve(result)
            }).catch(err=>{
                reject(err)
            })
        })
    }
}